
package Graphics;

import java.awt.event.*;
import javax.swing.Timer;

/**
 *
 * @author mhfowler
 */
public class MyTimer extends Timer {

    DrawingPanel draw;
    int count;

    public MyTimer(DrawingPanel panel) {
        super(50, null);
        addActionListener(new TickListener(this));
        //set up an association with
        draw = panel;
        count = 0;
    }

        private class TickListener implements ActionListener {

            public TickListener(MyTimer a) {
                parent = a;
            }

            MyTimer parent;

            public void actionPerformed(ActionEvent e) {
                if (count <500) {
                    draw.repaint();
                    count++;
                }
                else {
                    parent.stop();
                }
            }
        }
}